import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score

# 1. 读取数据
data = pd.read_csv('bilibili_videos.csv')

# 2. 数据预处理
# 假设已经对数据进行了清洗和编码处理

# 3. 特征工程
# 假设已经构造了新特征

# 4. 划分训练集和测试集
X = data[['点赞数', '播放量', '评论数', '弹幕数', '新特征1', '新特征2']]
y = data['是否进入热搜榜前十']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# 5. 模型训练
model = RandomForestClassifier()
model.fit(X_train, y_train)

# 6. 模型评估
y_pred = model.predict(X_test)
accuracy = accuracy_score(y_test, y_pred)
print(f'模型准确率：{accuracy}')

# 7. 模型应用
# 假设有新的视频数据 new_data
# predicted = model.predict(new_data)
# print(predicted)
